//
//  SharpnessMenuView.m
//  PigMarket
//
//  Created by mac on 2019/7/5.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "SharpnessMenuView.h"

@interface SharpnessMenuView ()
/**
 标准
 */
@property (nonatomic , strong) UIButton *normalBtn;
/**
 流畅
 */
@property (nonatomic , strong) UIButton *fluidBtn;
/**
 高清
 */
@property (nonatomic , strong) UIButton *HDBtn;

@end
static SharpnessMenuView *instance = nil;
@implementation SharpnessMenuView
+ (instancetype)sharedInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[SharpnessMenuView alloc] init];
    });
    return instance;
}
#pragma mark - init method
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self addSubview:self.normalBtn];
    [self addSubview:self.fluidBtn];
    [self addSubview:self.HDBtn];
}

- (void)initLayout {
    // 布局子控件
    [self.normalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(ScaleHeight(40));
        make.top.mas_equalTo(0);
    }];
    [self.fluidBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(ScaleHeight(40));
        make.top.mas_equalTo(self.normalBtn.mas_bottom);
    }];
    [self.HDBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(ScaleHeight(40));
        make.top.mas_equalTo(self.fluidBtn.mas_bottom);
        make.bottom.mas_equalTo(0);
    }];
}
- (void)menuBtnClick:(UIButton *)button {
//    switch (button.tag) {
//        case SharpnessMenuTypeNormal:
//
//            break;
//        case SharpnessMenuTypeFluid:
//
//            break;
//        case SharpnessMenuTypeHD:
//
//            break;
//        default:
//            break;
//    }
    if (self.sharpnessMenuBlock) {
        self.sharpnessMenuBlock(button.tag);
    }
}
#pragma mark - getter and setter
- (UIButton *)normalBtn {
    if (!_normalBtn) {
        _normalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_normalBtn setTitle:@"标清" forState:UIControlStateNormal];
        [_normalBtn setTitleColor:[UIColor colorWithHexString:@"#D2D2D2"] forState:UIControlStateNormal];
        _normalBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        _normalBtn.tag = 100;
        [_normalBtn addTarget:self action:@selector(menuBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _normalBtn;
}
- (UIButton *)fluidBtn {
    if (!_fluidBtn) {
        _fluidBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_fluidBtn setTitle:@"流畅" forState:UIControlStateNormal];
        [_fluidBtn setTitleColor:[UIColor colorWithHexString:@"#D2D2D2"] forState:UIControlStateNormal];
        _fluidBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        _fluidBtn.tag = 101;
        [_fluidBtn addTarget:self action:@selector(menuBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _fluidBtn;
}
- (UIButton *)HDBtn {
    if (!_HDBtn) {
        _HDBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_HDBtn setTitle:@"高清" forState:UIControlStateNormal];
        [_HDBtn setTitleColor:[UIColor colorWithHexString:@"#D2D2D2"] forState:UIControlStateNormal];
        _HDBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        _HDBtn.tag = 102;
        [_HDBtn addTarget:self action:@selector(menuBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _HDBtn;
}
@end
